//
// Created by xili on 2024/8/30 20:52.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution1 {
public:
    int maximumScore(int a, int b, int c) {
        priority_queue<int> pq;
        pq.push(a);
        pq.push(b);
        pq.push(c);
        int ans = 0;
        while (1) {
            int first = pq.top();
            if (!first) {
                break;
            }
            pq.pop();
            int second = pq.top();
            if (!second) {
                break;
            }
            pq.pop();
            pq.push(--first);
            pq.push(--second);
            ans++;
        }
        return ans;
    }
};

class Solution2 {
public:
    int maximumScore(int a, int b, int c) {
        int sum = a + b + c;
        int maxVal = max({a, b, c});
        if (sum - maxVal < maxVal) {
            return sum - maxVal;
        } else {
            return sum / 2;
        }
    }
};